﻿<%@ WebHandler Language="C#" Class="ValidateCode" %>

using System;
using System.Web;
using Ivony.Web;
using System.Drawing;
using System.Web.SessionState;
using System.Drawing.Drawing2D;

public class ValidateCode : IHttpHandler, IRequiresSessionState
{

  public void ProcessRequest( HttpContext context )
  {
    context.Response.ContentType = "image/png";
    context.Response.Cache.SetCacheability( HttpCacheability.NoCache );
    System.IO.MemoryStream stream = new System.IO.MemoryStream();

    string validateCode = ValidateCodeUtility.GetValidateCode( 7, "ABDEFHJKLMNPRSTUVWXY".ToCharArray() );
    context.Session["ValidateCode"] = validateCode;


    Brush foreBrush = new SolidBrush( Color.Black );
    Brush backBrush = new SolidBrush( Color.WhiteSmoke );


    ValidateCodeUtility.MakeValidateCodeImage( validateCode, new Font( "Arial", 11, FontStyle.Italic ), new Size( 110, 24 ), foreBrush, backBrush, 14, 4, 1.5f, 3, 1, 3, stream );

    stream.WriteTo( context.Response.OutputStream );
  }

  public bool IsReusable
  {
    get
    {
      return false;
    }
  }

}